<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="renderer" content="webkit">

    <title>登录</title>
    <meta name="keywords" content="响应式后台">
    <meta name="description" content="Html5+CSS3等现代技术">

    <%@include file="/pages/head/head.jsp" %>
  </head>
  
  <body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">SL</h1>

            </div>
            <h3>欢迎使用 校园助手后台管理系统</h3>

            <form class="m-t"  id="users" name="users" method="post">
            <!-- <input type="hidden" name="method" value="userLogin" /> -->
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="用户名" id="userAccount" name="userAccount" >
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" id="password" name="password" >
                </div>
                <button type="button" class="btn btn-primary block full-width m-b" id="submitbutton" onclick="checkFyFhSubmit()">登 录</button>


                <p class="text-muted text-center"> <a href="index.jsp"><small>忘记密码了？</small></a> 
                </p>

            </form>
        </div>
    </div>

   <%@include file="/pages/head/foot.jsp" %>

<script type="text/javascript">


/** 表单验证  **/
function validateForm(){
	if($("#userAccount").val()==""){
		alert("请输入用户名");
		return false;
	}
	if($("#password").val()==""){
		alert("请输入密码");
		return false;
	}
	return true;
}

 function checkFyFhSubmit(){
	 validateForm();
	$.ajax({
		type:"POST",
		url:"${pageContext.request.contextPath}/users/userLogin.do",
		data:$("#users").serialize(),
		async: true,
		dataType: "text", 
			error: function(request) {alert("登录失败！"+request.responseText);},
		success:function(data){
			var result=String($.trim(data));
			if(result == "success"){
				alert("操作成功");
				window.location.href="${pageContext.request.contextPath}/pages/index.jsp";
			}
			else{
				alert("登录失败,账号或者密码错误");
				document.getElementById("password").value="";
			}
			
		}
	});
//return true;
} 




</script>
</body>
</html>
